package com.weixx.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


/**
 * 测试servlet
 * weicao
 */
public class HelloServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //1.获取前端参数
        String str=req.getParameter("method");
        System.out.println(str);
        if (str.equals("add")){
            req.getSession().setAttribute("msg","添加用户");
        }else if(str.equals("delete")){
            req.getSession().setAttribute("msg","删除用户");
        }

        //2.调用业务层//3.视图转发或者重定向
        req.getRequestDispatcher("/WEB-INF/jsp/hello.jsp").forward(req,resp);
        //forward（）,转发的同时将参数继续传递




    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
}
